
import json

from flask import Flask, request, jsonify
import redis

# redis_conn = redis.StrictRedis(host='r-bp162522qrwjh5e7jhpd.redis.rds.aliyuncs.com', port=6379,
#                                             password='123sdmmh568%$#vs*!', db=21)


redis_conn = redis.StrictRedis(host='r-bp1y4wxs1fa8vxd1xspd.redis.rds.aliyuncs.com', port=6379,
                                            password='Jison0820', db=0)
app = Flask(__name__)


@app.route('/Message/Qrcode/Obtain', methods=['GET','POST'])
def process_data():


    if request.method == 'POST':
        args_data = request.get_json()
        user_id = args_data["user_id"]
        qrcode = args_data["qrcode"]

        redis_conn.set('dy_message_qrcode:{}'.format(user_id), qrcode)
        redis_conn.expire('dy_message_qrcode:{}'.format(user_id), 60)
        # redis_conn.set('dy_center_qrcode_status:{}'.format(user_id), '6')
        # redis_conn.expire('dy_center_qrcode_status:{}'.format(user_id), 300)
        return "获取成功"

    else:
        aa = request.args["qrcode"]
        print(aa)



if __name__ == '__main__':

    app.run(host='0.0.0.0',port=5002,threaded=True)
